import {localDB} from '@/utils/utils';
import {LOGIN_KEY, STATION_KEY, SETTING_KEY} from '@/constants';

export const User = {
  getUserInfo() {
    return localDB.get(LOGIN_KEY);
  },
  setUserInfo(token) {
    console.log(LOGIN_KEY);
    return localDB.set(LOGIN_KEY, token);
  },
  removeUserInfo() {
    localDB.remove(STATION_KEY);
    return localDB.remove(LOGIN_KEY);
  }
};
export const Station = {
  getStations() {
    return localDB.get(STATION_KEY);
  },
  setStations(info) {
    return localDB.set(STATION_KEY, info);
  },
  removeStations() {
    return localDB.remove(STATION_KEY);
  }
};

export const Setting = {
  getUserSettings() {
    return localDB.get(SETTING_KEY);
  },
  setUserSettings(info) {
    return localDB.set(SETTING_KEY, info);
  },
  removeUserSettings() {
    return localDB.remove();
  }
};

export const clear = function () {
  localDB.clear();
};
